The technology described herein relates to game machines and game programs. More specifically, the technology described herein relates to a game machine and a game program for carrying out game processing to display a state in which a first object casts a shadow formed by light from a light source on a second object in a virtual three-dimensional (3-D) game space.
When computers for computer graphics perform computer graphics processing such as shadow processing, techniques such as ray tracing and radiosity have been used to achieve computer graphics with realistic shadows.
When game machines performs 3-D game processing, a game image has to be generated within one frame ( 1/30 second or 1/60 second). Therefore, time-consuming computer graphics processing cannot be introduced to 3-D game processing. To present shadows of characters in a 3-D game space, shadow images (or shadow polygons) are often provided in advance to conventional game machines, and are placed where appropriate, such as under the characters. However, such shadow images can hardly achieve realistic shadows.
In recent years, highly-improved performance of the game machines has enabled shadow processing such as shadow mapping and shadow volume techniques. Therefore, shadows that are more realistic than those in conventional art can be displayed.
In the shadow mapping technique, a shadow is rendered in the following steps 1 to 5:
(Step 1) Take a position of a light source in game space as a viewpoint, and store depth information of objects viewed from the viewpoint in a table.
(Step 2) Render the objects viewed from a rendering viewpoint, and store depth information of the objects viewed from the rendering viewpoint in a Z buffer.
(Step 3) Formulate a transformation equation for transforming a point on a screen with reference to positional information thereof for comparison with depth information corresponding to the point stored in the table in step 1.
(Step 4) Use the equation formulated in step 3 to compare the depth information of the point and the corresponding depth information stored in the table in step 1. If they are not equal in value, there is a light-obstructive object between the point and the light source. In this case, perform processing for decreasing luminance.
(Step 5) Perform the processing of step 4 for every point on the screen.
In the above shadow mapping technique, performing various processing such as depth information generation based on the light source and copy processing is required. With hardware whose frequency band for memory transfer is narrow, such processing occupies a bus in the hardware, thereby leading to an increase in processing load. Moreover, additional memory for storing the depth information is required.
In the shadow volume technique, a shadow is rendered as follows. First, a contour of an object is extended in a direction of light from a light source in a game space to obtain a shadowed space (shadow volume). Then, front faces and back faces of the shadowed space are rendered by, for example, using a stencil buffer, to obtain an area where the shadow is actually cast. Then, the shadow is rendered on an area of the game image corresponding to the obtained area.
In the above shadow volume technique, extracting the contour of the object and generating a shadowed space extended from the contour in the light direction require a large amount of processing load. Also, rendering the entire shadowed space by using the stencil buffer requires a large amount of processing load.
That is, even with highly-improved performance of game machines, the large processing load required for generating realistic game images still impairs an entertaining aspect in gameplay. Therefore, it is desirable to achieve processing for generating realistic images with less processing load.